﻿#include "SetScriptLoopDialog.h"

#include "QRegExpValidator"
#include "qmessagebox.h"

SetScriptLoopDialog::SetScriptLoopDialog(QWidget* parent):QDialog(parent)
{
  ui.setupUi(this);
  QRegExp regExp("^(\\d+)?$");
  ui.lineEdit_loopCount->setValidator(new QRegExpValidator(regExp, this));
  connect(ui.pushButton_confirm, &QPushButton::clicked, this, &SetScriptLoopDialog::accept);
  connect(ui.pushButton_cancel, &QPushButton::clicked, this, &SetScriptLoopDialog::reject);
  setFixedSize(size());
}
SetScriptLoopDialog::~SetScriptLoopDialog()
{
}
void SetScriptLoopDialog::accept()
{
  QString temp = ui.lineEdit_loopCount->text();
  if (temp.isEmpty())
    {
      QMessageBox::information(this, QStringLiteral("消息"), QStringLiteral("循环次数不能为空"));
      return;
    }
  QDialog::accept();
}
int SetScriptLoopDialog::getLoopCount()
{
  return ui.lineEdit_loopCount->text().toInt();
}
